package org.mxp.demo8;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import org.mxp.utils.RabbitMQUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class SendObj {
    public static void main(String[] args) throws Exception {
        // 交换机名称
        String EXCHANGE_NAME = "topic_logs";
        // 获取信道
        Channel channel = RabbitMQUtils.getChannel();
        // 声明交换机，第一个参数为交换机名称，第二个参数为交换机类型
        channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.TOPIC);
        // 发送的消息集合
        ArrayList<String> msgList = new ArrayList<String>() {{
            add("quick.orange.rabbit");
            add("azy.orange.elephant");
            add("quick.orange.fox");
            add("lazy.brown.fox");
            add("lazy.pink.rabbit");
            add("quick.brown.fox");
            add("quick.orange.male.rabbit");
            add("lazy.orange.male.rabbit");
            add("lazy.");
            add("lazy");
        }};
        for (String item: msgList) {
            channel.basicPublish(EXCHANGE_NAME, item, null, item.getBytes());
        }
        System.out.println("消息发送完毕");
    }
}
